<?php

require_once("inc.member.php");



$this_title="$vars[member_title] &raquo; ".__("Volume");

$page_title=__("Volume");

$content_title=__("Volume");



$item_per_page=$vars["user_item_per_page"];



require_once("inc.desk_select.php");

$max_dlot=mysql_result(mysql_query("select max_dlot from gg_users where id=".$uid), 0) or 0;

$k=0;

$r=mysql_query("select level,sum(volume_type) as volume_type,(leg1_amount-volume_type) as leg1_amount,(leg2_amount-volume_type) as leg2_amount from gg_member_comm where uid=".$uid." and type='p' group by level order by level,cdate desc");
while($rs = mysql_fetch_assoc($r))
{
	if((($rs['leg1_amount']+$rs['volume_type'])/10000) > $max_dlot){
		$leg1_amount = $max_dlot;
	}else{
		$leg1_amount = (($rs['leg1_amount']+$rs['volume_type'])/10000);
	}
	
	if((($rs['leg2_amount']+$rs['volume_type'])/10000) > $max_dlot){
		$leg2_amount = $max_dlot;
	}else{
		$leg2_amount = (($rs['leg2_amount']+$rs['volume_type'])/10000);
	}
	
	$his_row.="

	 <tr class='row$k'>
	
	  <td>".$rs["level"]."</td>
	
	  <td class='number'>".$leg1_amount."/".$max_dlot."</td>
	
	  <td class='number'>".$leg2_amount."/".$max_dlot."</td>
	
	  <td class='number'>".($rs['volume_type']/10000)."</td>
	
	  <td>".($max_dlot-($rs['volume_type']/10000))."</td>
	
	 </tr>";
	
	 $k=1-$k;
}

/*
//#####LIST EWALLET HISTORY#####

$count_sql="select count(*) from $db->member_comm where uid='$uid' and type='p'";

$record_sql="select * from $db->member_comm where uid='$uid' and type='p' order by id limit <%limit_start%>, <%limit%>";

$cur_page=$_GET["nav"];

$total_record=@mysql_result(mysql_query($count_sql), 0);

$total_page=ceil($total_record/$item_per_page);

$page=($cur_page? ($cur_page>$total_page? $total_page : ($cur_page<1? 1 : $cur_page)) : 1);

$limit_start=($page-1)*$item_per_page;

$nav_link=format_page($page, $total_page, 15);

$this_page_total=@mysql_num_rows($r=mysql_query(str_replace("<%limit_start%>", $limit_start, str_replace("<%limit%>", $item_per_page, $record_sql))));

$k=0;

for($i=0;$i<$this_page_total;$i++){

 $p=mysql_fetch_assoc($r);

$level[$p['level']] -= $p['volume_type']/10000;

 $his_row.="

 <tr class='row$k'>

  <td>".($i+1)."</td>

  <td>".$p["bonus_date"]."</td>

  <td>".$p["descr"]."</td>

  <td class='number'>".number_format($p['leg1_amount']/10000, 2)."</td>

  <td class='number'>".number_format($p['leg2_amount']/10000, 2)."</td>

  <td class='number'>".$p['level']."</td>

  <td>".$level[$p['level']]."/".$max_dlot."</td>

 </tr>";

 $k=1-$k;

}



//listing text

$listing_text=replace_tag(__("<%x%> <%title%> <%record%>."), array("<%x%>"=>"$total_record", "<%title%>"=>__('volume'), "<%record%>"=>$total_record>1? __("records") : __("record")));
*/


//listing

$his_list=

"<h2>".replace_tag(__("<%title%>"), array("<%title%>"=>__('Level')))."</h2>

<table class='pbl_table'>

 <tr class='pbl_header'>

  <td>".__("Level")."</td>

  <td>".__("Left")."</td>

  <td>".__("Right")."</td>

  <td>".__("Matched")."</td>

  <td>".__("Available")."</td>

 </tr>

 $his_row

</table>

$nav_link";



$content=$inc_wallet_select.$his_list;

print format_member_page($content, $this_title, $content_title, $css . $inc_jvscript);

?>